<template>
  <view class="whole">
    <view class="transferAll">
      <view class="" v-if="list">
        <block v-for="(item, index) in list" :key="index">
          <view class="list_whole">
            <view class="list_time">
              <text>{{ item.product.name }}</text>
              <text>{{ item.created_at }}</text>
            </view>
            <view class="list_money">
              <text>{{ item.point }}</text>
            </view>
          </view>
        </block>
      </view>
    </view>
    <empty :show="list.length == 0"></empty>
  </view>
</template>

<script>
import api from "../../api/api";
import tip from "@/utils/tip.js";
import empty from "@/components/empty/empty";
export default {
  data() {
    return {
      list: [],
      liststate: false,
      page: 1,
      typeid: 1,
    };
  },
  onLoad() {},
  onShow() {
    this.record();
  },
  onReachBottom() {
    this.page++;
    this.record();
  },
  onPullDownRefresh() {
    this.page = 1;
    this.record();
  },
  methods: {
    switchtype(id) {
      this.typeid = id;
      this.page = 1;
      this.record();
    },
    async record() {
      let res = await api.exchangeLog({
        query: {
          page: this.page,
        },
      });
      if (res.code == 0) {
        if (this.page == 1) {
          this.list = res.data;
          if (res.data.length == 0) {
            this.pagestate = true;
          }
        } else {
          if (res.data.length > 0) {
            this.list = [...this.list, ...res.data];
          }
        }
      }
    },
  },
};
</script>

<style lang="scss" scoped>
@import "../../style/yuanchuang.scss";
.whole {
  width: 100%;
  height: 100%;
  background-color: $bg-color1;
  min-height: calc(100vh - 44px);
  .type {
    padding: 3rpx;
  }
  .toptype {
    border-radius: 8px;
    background-color: #101428;
    height: 44px;
    margin: 30rpx 30rpx 0;
    display: flex;
    justify-content: center;
    line-height: 44px;
    align-content: center;
    .division {
      width: 4rpx;
      height: 19px;
      background: #343744;
      margin-top: 25rpx;
    }
    .typenow {
      font-size: 14px;
      font-weight: 500;
      color: #39a2ff;
      margin: 0 85rpx;
      transition: color 1s;
    }
    .typefuture {
      font-size: 14px;
      font-weight: 500;
      color: #cccccc;
      margin: 0 85rpx;
    }
  }
  .transferAll {
    width: 100%;
    padding: 3rpx 0;
    border-radius: 15rpx;
    .list_whole {
      height: 140rpx;
      // margin: 30rpx;
      padding: 0 30rpx;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-content: center;
      border-bottom: 2rpx solid #292b2b;
      background: $bg-color1;
      .list_time {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        margin: 30rpx 0;
        text:nth-child(1) {
          font-size: 16px;
          color: #ffffff;
        }
        text:nth-child(2) {
          font-size: 12px;
          color: #bbbbbe;
        }
      }
      .list_money {
        color: #ffffff;
        text {
          font-size: 18px;
          font-weight: 600;
          line-height: 140rpx;
        }
      }
    }
  }
}
</style>
